package com.medusa.aps.business.modules.board.mp.service;

import com.medusa.aps.business.model.pagination.Page;
import com.medusa.aps.business.modules.board.model.input.WorkshopProductionDetailMultiQueryParam;
import com.medusa.aps.business.modules.board.model.input.WorkshopProductionDetailSingleQueryParam;
import com.medusa.aps.business.modules.board.model.input.WorkshopProductionStatisticsParam;
import com.medusa.aps.business.modules.board.model.output.WorkshopProductionDetailVO;
import com.medusa.aps.business.modules.board.model.output.WorkshopProductionEquipmentVO;
import com.medusa.aps.business.modules.board.model.output.WorkshopProductionStatisticsVO;
import com.medusa.aps.business.modules.board.mp.entity.WorkshopProductionStatistics;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>车间维度生产任务服务接口</p>
 * @author An.Yan
 */
public interface IWorkshopProductionService {

    /**
     * 分页查询车间维度排产任务统计数据
     * @param queryParam {@link WorkshopProductionStatisticsParam}
     * @return {@link WorkshopProductionStatisticsVO}
     */
    WorkshopProductionStatisticsVO pageWorkshopProductionTaskStatistics(WorkshopProductionStatisticsParam queryParam);

    /**
     * 分页查询车间单日生产详情
     * @param queryParam 查询参数,参考 {@link WorkshopProductionDetailSingleQueryParam}
     * @return 车间生产详情分页数据,参考 {@link WorkshopProductionDetailVO}
     */
    Page<WorkshopProductionDetailVO> pageWorkshopProductionDetail(WorkshopProductionDetailSingleQueryParam queryParam);

    /**
     * 分页查询车间多日生产详情
     * @param queryParam 查询参数,参考 {@link WorkshopProductionDetailMultiQueryParam}
     * @return 车间生产详情分页数据,参考 {@link WorkshopProductionDetailVO}
     */
    Page<WorkshopProductionDetailVO> pageWorkshopProductionDetail(WorkshopProductionDetailMultiQueryParam queryParam);

    /**
     * 统计给定的车间ID在指定的日期已排产设备数量
     * @param workshopId 车间ID集合
     * @param statDate 统计时间
     * @return {@link WorkshopProductionEquipmentVO}集合
     */
    List<WorkshopProductionEquipmentVO> statisticsEquipment(Integer workshopId, LocalDate statDate);

    /**
     * 获取指定车间的可用设备数量,如果 {@code workshopIds}为空,则返回所有车间可用设备数量
     * @param workshopIds 车间ID集合
     * @return 指定车间的可用设备数量
     */
    Map<Integer, Long> statisticsAvailableEquipment(List<Long> workshopIds);

    /**
     * 根据workshopID + statDate 查询统计数据
     * @param statisticsEntities 统计数据参数
     * @return 与workshopID + statDate相匹配的统计数据
     */
    List<WorkshopProductionStatistics> selectStatisticsByCondition(List<WorkshopProductionStatistics> statisticsEntities);


    /**
     * 批量保存统计数据,根据workshopId和statisticsDate两个字段检查统计数据是否存在,若存在则更新;否则插入
     * @param statisticsEntities 待保存的统计数据
     */
    void saveStatisticsData(List<WorkshopProductionStatistics> statisticsEntities);
}
